/**
 * @fileoverview
 * TODO doc me
 */

function initialiseApplication() {
	
	var logReader = new YAHOO.widget.LogReader("logger");
	
	log("instantiate a service for the bdgp image widget");
	var service = new flyui.bdgp.Service("../../../data/bdgp");
	
	log("instantiate a renderer for the bdgp image widget");
	var renderPane = document.getElementById("bdgpImageWidget");
	//call to the DefaultRenderer without passing the renderpane in now (the refactor)
	var renderer = new flyui.bdgp.ImageWidget.DefaultRenderer();	
	renderer.setCanvas(renderPane);
	
	log("instantiate a bdgp image widget");
	widget = new flyui.bdgp.ImageWidget(service, renderer);
	
	log("hook form submission to widget call");
	YAHOO.util.Event.addListener("queryForm", "submit", onFormSubmit);
	
	log("application loaded, showing main pane");
	flyui.mvcutils.hide(document.getElementById("loadingPane"));
	flyui.mvcutils.show(document.getElementById("applicationPane"));
}

function onFormSubmit(event) {
	log("form submitted");
	
	var query = document.getElementById("queryInput").value;
	log("query: "+query);
	
	widget.findImagesByAnyGeneLabel(query);
}

YAHOO.util.Event.onDOMReady(initialiseApplication);